#ifndef UNIT_H
#define UNIT_H

#include <Gosu/Gosu.hpp>
#include <Gosu/Utility.hpp>
#include <Gosu/AutoLink.hpp> // Makes life easier for Windows users compiling this.

#include "boost/multi_array.hpp"
#include <vector>
#include <cmath>

#include "Position.h"
#include "objects.h"


class Unit
{


public:


	Unit(Gosu::Graphics& gfx, boost::multi_array<Cell, 2> *grid, PosDouble a);

	void move(std::vector<PosDouble> a);
	void augmentMove(std::vector<PosDouble> a);
	void update(PosDouble &scrollPosDouble);
	PosDouble getPosDouble();
	PosDouble getGoal();

	bool selected;

private:

	bool adjustAngle(double& angle, PosDouble goalDir, double rotationSpeed);
	PosDouble getSplinePos(double t, unsigned int moveIndex);

	boost::multi_array<Cell, 2> *bigGrid;
	Gosu::Graphics * graphics;


	PosDouble pos, oldPos;
	double speed, angle, turretAngle, rotationSpeed, t, oldT, maxTryAngle;
	unsigned int moveIndex;

	std::vector<PosDouble> movement;

    boost::scoped_ptr<Gosu::Image> tank;
    boost::scoped_ptr<Gosu::Image> turret;
	boost::scoped_ptr<Gosu::Image> selectIm;

};

#endif